package com.mdnote.practice.bit;

/**
 * @author Rhythm-2019
 * @version 1.0
 * @date 2020/10/17
 * @description 位1的个数
 */
public class LeetCode191 {
    public int hammingWeight(int n) {
        int count = 0;
        while(n != 0) {
            n = n & (n - 1);
            count++;
        }
        return count;
    }
}
